/**
 * @description 数据存储统一管理
 */

import config from '@/config/index.js'
const { tokenKey, userLocale, address, isActive} = config

function setToken(data){
	uni.setStorageSync(tokenKey, data)
	getApp().globalData.isLogin = true
}
function getToken(){
	return uni.getStorageSync(tokenKey)
}
function removeToken(){
	uni.removeStorageSync(tokenKey)
	getApp().globalData.isLogin = false
}

function setLocale(data){
	uni.setStorageSync(userLocale, data)
}
function getLocale(){
	return uni.getStorageSync(userLocale)
}
function removeLocale(){
	uni.removeStorageSync(userLocale)
}

function setAddress(data){
	uni.setStorageSync(address, data)
}
function getAddress(){
	return uni.getStorageSync(address)
}
function removeAddress(){
	uni.removeStorageSync(address)
}

function setActive(data){
	uni.setStorageSync(isActive, data)
}
function getActive(){
	return uni.getStorageSync(isActive)
}
function removeActive(){
	uni.removeStorageSync(isActive)
}

export {
	setToken,
	getToken,
	removeToken,
	setLocale,
	getLocale,
	removeLocale,
	setAddress,
	getAddress,
	removeAddress,
	setActive,
	getActive,
	removeActive
}